package easy;

import java.util.HashMap;
import java.util.Map;

public class Solution_1507 {
    String[] months = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};

    public String reformatDate(String date) {
        Map<String, Integer> monthMap = new HashMap<>();
        for (int i = 0; i < months.length; i++) {
            monthMap.put(months[i], i + 1);
        }

        String[] split = date.split(" ");
        String month;
        if (monthMap.get(split[1]) < 10) {
            month = "0" + monthMap.get(split[1]);
        } else {
            month = "" + monthMap.get(split[1]);
        }
        String day;
        if (split[0].length() == 3) {
            day = "0" + split[0].substring(0, split[0].length() - 2);
        } else {
            day = "" + split[0].substring(0, split[0].length() - 2);
        }
        return String.format("%s-%s-%s", split[2], month, day);
    }

    public static void main(String[] args) {
        Solution_1507 model = new Solution_1507();
    }
}
